Repository navigation
Conversation
UpdateStatistics.remove_statistics assigned self._updates instead of appending to it, so any set_statistics call staged earlier in the same chain was silently dropped. For example, table.update_statistics().set_statistics(f).remove_statistics(id).commit() only removed the statistics and never registered f. This is the usage shown in the class docstring and in the API docs. Append with += like set_statistics does, and add a regression test that chains set_statistics and remove_statistics and checks that both updates are staged and applied. Follow-up to apache#3557.
…test Make the precondition explicit: the fixture already has statistics for both snapshots, which is why remove_statistics targets the previous one. Assert on the resulting table metadata only, instead of the private staged updates.
ebyhr
left a comment
There was a problem hiding this comment.
Looks good to me. There's no similar bug in other updates as far as I checked.
|
@kevinjqliu could you take a look at this? |
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions. |
|
This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time. |
Rationale for this change
The
remove_statistics()method on the statistics update builder is dropping updates which are queued before it.This PR supersedes #3557
When
remove_statistics()is called, the update queued byset_statistics()gets dropped, so at commit, only the remove is preserved. The side effects of this could be that the query engines plan with stale statistics.This happens as
=is used inremove_statistics()method.=replaces the builder's list of pending updates instead of appending to it.set_statistics()is using+=.The fix is to use
+=inremove_statistics()method, like inset_statistics().Are these changes tested?
Yes,
test_update_statistics_set_then_remove_keeps_both_updates(tests/table/test_init.py) has been added as a new unit test.Consider a table that has snapshots s2 and s1, each with its statistics files.
The test sets a new statistics file for s2, then removes s1's statistics.
After the commit, s2 points to the new file and s1 has no statistics. Both changes are applied.
On the main branch, this test fails, the
set_statistics()for s2 gets dropped, s2 keeps pointing to its old file.With the fix, make test, 4,254 passed, and make lint passing.
Are there any user-facing changes?
No API changes. set-then-remove now applies both updates.
AI disclosure
AI was used to write the code, tests and for local verification.